const EXCELJS = require('exceljs');
const fs = require('fs')
const WORKBOOK = new EXCELJS.Workbook();


async function readExcel(filePath) {
    await WORKBOOK.xlsx.readFile(filePath);
    const SHEET = WORKBOOK.worksheets[0];
    let arr = []
    SHEET.eachRow((row, rowNumber) => {
        let obj = {
            "id": 'SB'+new Date().getTime()+rowNumber,
            "title": row.getCell(1).text,
            "abs": row.getCell(8).text,
            "time": "2023-05-14",
            "price": Number(row.getCell(5).text) || 0,
            "no":  row.getCell(2).text,
            "u": row.getCell(3).text,
            "r":  row.getCell(6).text,
            "p": row.getCell(7).text,
        }
        arr.push(obj)
    });
    let p = {
        trademark:arr
    }
    fs.writeFile('trademark.json', JSON.stringify(p), () => {
        console.log('write');
    })
}

readExcel('./trademark.xlsx');